home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Interactive Web Graphics with Shout 3D
/
Interactive Web Graphics With Shout 3D.iso
/
mac
/
Code
/
Chapter09
/
StartPausePanel.java
< prev
next >
Wrap
Text File
|
2000-08-27
|
2KB
|
74 lines
package applets;
import shout3d.*;
import shout3d.core.*;
import shout3d.math.*;
public class StartPausePanel extends Shout3DPanel implements DeviceObserver {
TimeSensor timer;
boolean started = false;
public StartPausePanel (Shout3DApplet applet){
super(applet);
}
public void customInitialize() {
addDeviceObserver(this,"MouseInput", null);
timer =(TimeSensor) getNodeByName("world-TIMER");
}
protected void finalize() {
removeDeviceObserver(this,"MouseInput");
}
public boolean onDeviceInput(DeviceInput di, Object userData) {
MouseInput mi = (MouseInput) di;
switch (mi.which){
case MouseInput.DOWN:
//if animation is not started
if (!started) {
timer.start();
started = true;
return true;
}
//if already started
else {
//if it's paused, unpause it
//or vice versa
if (timer.isPaused()) {
timer.setPaused(false);
return true;
}
else {
timer.setPaused(true);
return true;
}
}
}//end of switch
return false;
}
} //end of class